#region Using directives

using System;

using FighterChessEngine.Enum;

#endregion

namespace FighterChessEngine.FC_Player
{
    /// <summary>
    /// Summary description for Player.
    /// </summary>
    public class Player
    {
        #region Atributes
        private Owner owner;
        private string name;
        private bool active;
        private bool win;
        #endregion

        #region Properties
        public Owner Owner
        {
            get { return owner; }
            set { owner = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public bool Active
        {
            get { return active; }
            set { active = value; }
        }
        #endregion

        #region Methods
        public Player()
        {   
            active = false;
            name = "";
            owner = Owner.None;
            win = false;
        }

        public Player(string name, Owner owner)
            : this()
        {
            this.name = name;
            this.owner = owner;
        }

        public Player(string name, Owner owner, bool active)
            : this(name, owner)
        {
            this.active = active;
        }

        public Player(string strPlayer)
            : this()
        {
            // name,owner,active
            // ex: p1,1,true
            char[] sep = { ',' };
            string[] arrInfos = strPlayer.Split(sep);

            name = arrInfos[0];
            owner = (Owner)int.Parse(arrInfos[1]);
            active = bool.Parse(arrInfos[2]);
        }

        public string ToSaveString()
        {
            string str = "";
            str += name + ",";
            int iOwner = (int)owner;
            str += iOwner.ToString() + ",";
            str += active.ToString();

            return str;
        }

        public void Win()
        {
            win = true;
        }

        public void Lose()
        {
            win = false;
        }
        #endregion
    }
}
